package com.jswl.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jswl.demo.entity.User;
import com.jswl.demo.mapper.UserMapper;

@RestController
public class UserController {
	@Autowired
	private UserMapper userMapper;
	@GetMapping("/findUserById")
	public User findUserById() {
		 User user = userMapper.findUserById(1);
		return user;
	}
	
	@GetMapping("/findAll")
	public List<User> findAll(){
		
		return userMapper.findAll();
	}
	@GetMapping("/deleteById")
	public String deleteById() {
		
		userMapper.deleteById(3);
		return "删除成功";
	}
	
	
	@GetMapping("/insertUser")
	public String insertUser() {
		User user = userMapper.insertUser();
		user.setId(3);
		user.setPassword("ppp");
		user.setUsername("oooo");
		return "新增成功";
	}
}
